//  Program converted from C to C++
//  stdio.h library was changed to C++ iostream library
//  Multiline comments was changed to one line comment
//  the macro definition of the constant was changed for the word "const"
//  array was changed for a  vector, teh library vector was included
//  the function sum is now inline
//  reference is used instead of pointer


#include <iostream>
#include <vector>

using namespace std;

const int VECTOR_SIZE = 40;

inline void sum( int& p, int n, vector<int> d ){
        int i;
        p = 0;
        for(i = 0; i < n; ++i)
        p = p + d[i];
}

int main(){

        int i;
        int accum = 0;
        vector<int> data( VECTOR_SIZE );

        for(i = 0; i < VECTOR_SIZE; ++i)
                data[i] = i;

        sum( accum, VECTOR_SIZE, data );
        cout << "sum is " <<accum << "\n";

        return 0;
}

